package LatexForResults;

import java.io.BufferedWriter;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;

import Definitions.GraphClass;
import Global.ConstantVariable;
import GraphProperties.PropertiesOfGraphClass;
import Result.ResultClassListClass;

public class LatexUtilityForPredefinedDatasetsResultsClass {
	
	static int predefinedDatasetIndex = 0;
	
	public static void increasePredefinedDatasetIndex()
	{
		predefinedDatasetIndex++;	
	}
	
/******************************************************************************************/
		
	public static class predefinedDatasetSummaryResultsTableCreatorClass
	{
		public static void printLatexpredefinedDatasetSummaryResultsTableHeaderFirstPartToTheFile(BufferedWriter out, String datasetName)
		{
			/*BufferedWriter out;

		FileWriter fstream = new FileWriter(fileAdditionalProperties);
	    BufferedWriter out = new BufferedWriter(fstream);*/

			try
			{
				out.write("\\begin{table}%[ht])");
				out.write("\n");
				out.write("\\centering");
				out.write("\n");
				out.write("\\caption{");
				out.write(datasetName);
				out.write(" Dataset Summary Results}");				
				out.write("\n");
				out.write("\\begin{tabular}{|l|");				
				for(int i=0; i<calculateNumberOfColumnsForSummaryTables(); i++)
					out.write("c|");
				out.write("}");
				out.write("\n");
				out.write("\\hline");
				out.write("\n");
				
				out.write("No ");
				
				if(ConstantVariable.ExecutionParameters.isContentOnlyExecutionEnabled)
					out.write("& A.(CO) ");
				
				if(ConstantVariable.ExecutionParameters.isLinkOnlyExecutionEnabled)
					out.write("& A.(LO) ");
				
				if(ConstantVariable.ExecutionParameters.isICAExecutionEnabled)
					out.write("& A.(ICA) ");
				
				if(ConstantVariable.ExecutionParameters.isMetaClassifierExecutionEnabled)
				{
					if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierAverageMethodEnabled)
						out.write("& A.(AVE) ");
					
					if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierMaxMethodEnabled)
						out.write("& A.(MAX) ");
					
					if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierProductMethodEnabled)
						out.write("& A.(PRD) ");
					
					if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierLocalAlphaMethodEnabled)
						out.write("& A.(wAVE) ");
					
					if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierDegreeFilterMethodEnabled)
						out.write("& A.(DF) ");
					
					if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierLocalBetaMethodEnabled)
						out.write("& A.(bAVE) ");
					
					if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierLocalAlphaMaxMethodEnabled)
						out.write("& A.(laMAX) ");
					
					if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierLocalBetaMaxMethodEnabled)
						out.write("& A.(lbMAX) ");
				}
				
				out.write("\\\\");
				out.write("\n");
				out.write("\\hline");
				out.write("\n");
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}

		}

		public static void addRecordToThePredefinedDatasetSummaryResultsTable(BufferedWriter localOutForPredefinedDatasetResultsSummaryFile, ArrayList<ResultClassListClass> resultsList)
		{
			try
			{
				
				ResultClassListClass resultsListForCO = resultsList.get(0);
				ResultClassListClass resultsListForLO = resultsList.get(1);
				ResultClassListClass resultsListForICA = resultsList.get(2);
				
				ResultClassListClass  resultsListForAVE  = resultsList.get(3);
				ResultClassListClass  resultsListForMAX  = resultsList.get(4);
				ResultClassListClass  resultsListForPROD = resultsList.get(5);
				ResultClassListClass  resultsListForLA   = resultsList.get(6);	
				ResultClassListClass  resultsListForDFMM   = resultsList.get(7);
				
				ResultClassListClass  resultsListForLB   = resultsList.get(8);
				
				ResultClassListClass  resultsListForLAMAX   = resultsList.get(9);
				ResultClassListClass  resultsListForLBMAX   = resultsList.get(10);
				

				/*
				int numberOfResultsForCO  DFMM 0;
				int numberOfResultsForLO = 0;
				int numberOfResultsForICA = 0;

				if(resultsListForCO != null)
					numberOfResultsForCO = resultsListForCO.size();

				if(resultsListForLO != null)
					numberOfResultsForLO = resultsListForLO.size();

				if(resultsListForICA != null)
					numberOfResultsForICA = resultsListForICA.size();


				System.out.println("numberOfResultsForCO:"+numberOfResultsForCO);
				System.out.println("numberOfResultsForLO:"+numberOfResultsForLO);
				System.out.println("numberOfResultsForICA:"+numberOfResultsForICA);
				  */
				 
				NumberFormat formatter = new DecimalFormat(ConstantVariable.Format_ConstantVariables.numberFormatToBeUsedForErrorBars);
				
				
				
				localOutForPredefinedDatasetResultsSummaryFile.write(predefinedDatasetIndex
						+ (resultsListForCO==null ? "" : "  & " + formatter.format(resultsListForCO.calculateAverageAccuracyObtained()) + " $\\pm$ " + formatter.format(resultsListForCO.findErrorBarOfAccuracyResults())) 
						+ (resultsListForLO==null ? "" : "  & " + formatter.format(resultsListForLO.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLO.findErrorBarOfAccuracyResults()))
						+ (resultsListForICA==null ? "" : "  & " + formatter.format(resultsListForICA.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForICA.findErrorBarOfAccuracyResults())) 
						+ (resultsListForAVE==null ? "" : "  & " + formatter.format(resultsListForAVE.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForAVE.findErrorBarOfAccuracyResults()))
						+ (resultsListForMAX==null ? "" : "  & " + formatter.format(resultsListForMAX.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForMAX.findErrorBarOfAccuracyResults()))
						+ (resultsListForPROD==null ? "" : "  & " +formatter.format(resultsListForPROD.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForPROD.findErrorBarOfAccuracyResults()))
						+ (resultsListForLA==null ? "" : "  & " + formatter.format(resultsListForLA.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLA.findErrorBarOfAccuracyResults()))
						+ (resultsListForDFMM==null ? "" : "  & " + formatter.format(resultsListForDFMM.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForDFMM.findErrorBarOfAccuracyResults()))
						+ (resultsListForLB==null ? "" : "  & " + formatter.format(resultsListForLB.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLB.findErrorBarOfAccuracyResults()))
						+ (resultsListForLAMAX==null ? "" : "  & " + formatter.format(resultsListForLAMAX.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLAMAX.findErrorBarOfAccuracyResults()))
						+ (resultsListForLBMAX==null ? "" : "  & " + formatter.format(resultsListForLBMAX.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLBMAX.findErrorBarOfAccuracyResults()))
						+ "\\\\");
				
				/*
				localOutForPredefinedDatasetResultsSummaryFile.write(predefinedDatasetIndex 
						+ "  & " + (resultsListForCO==null ? "-" :formatter.format(resultsListForCO.calculateAverageAccuracyObtained()) + " $\\pm$ " + formatter.format(resultsListForCO.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForLO==null ? "-" : formatter.format(resultsListForLO.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLO.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForICA==null ? "-" :formatter.format(resultsListForICA.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForICA.findErrorBarOfAccuracyResults())) 
						+ "  & " + (resultsListForAVE==null ? "-" :formatter.format(resultsListForAVE.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForAVE.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForMAX==null ? "-" :formatter.format(resultsListForMAX.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForMAX.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForPROD==null ? "-" :formatter.format(resultsListForPROD.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForPROD.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForLA==null ? "-" :formatter.format(resultsListForLA.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLA.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForDFMM==null ? "-" :formatter.format(resultsListForDFMM.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForDFMM.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForLB==null ? "-" :formatter.format(resultsListForLB.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLB.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForLAMAX==null ? "-" :formatter.format(resultsListForLAMAX.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLAMAX.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForLBMAX==null ? "-" :formatter.format(resultsListForLBMAX.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLBMAX.findErrorBarOfAccuracyResults()))
						+"\\\\");*/
				localOutForPredefinedDatasetResultsSummaryFile.write("\n");
				localOutForPredefinedDatasetResultsSummaryFile.write("\\hline");
				localOutForPredefinedDatasetResultsSummaryFile.write("\n");
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}

		public static void printLatexPredefinedResultsTableHeaderEndPartToTheFile(BufferedWriter out, String datasetName)	
		{		
			try
			{
				out.write("\\end{tabular}");
				out.write("\n");			
				out.write("\\label{table:");
				out.write(datasetName);
				out.write("DataSummaryResults}");
				out.write("\n");
				out.write("\\end{table}");
				out.write("\n");
				out.close();
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}
		
		public static int calculateNumberOfColumnsForSummaryTables()
		{
			int columnCount = 0;
			
			if(ConstantVariable.ExecutionParameters.isContentOnlyExecutionEnabled)
				columnCount++;
			
			if(ConstantVariable.ExecutionParameters.isLinkOnlyExecutionEnabled)
				columnCount++;
			
			if(ConstantVariable.ExecutionParameters.isICAExecutionEnabled)
				columnCount++;
			
			if(ConstantVariable.ExecutionParameters.isMetaClassifierExecutionEnabled)
			{
				if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierAverageMethodEnabled)
					columnCount++;
				
				if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierMaxMethodEnabled)
					columnCount++;
				
				if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierProductMethodEnabled)
					columnCount++;;
				
				if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierLocalAlphaMethodEnabled)
					columnCount++;
				
				if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierDegreeFilterMethodEnabled)
					columnCount++;
				
				if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierLocalBetaMethodEnabled)
					columnCount++;
				
				if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierLocalAlphaMaxMethodEnabled)
					columnCount++;
				
				if(ConstantVariable.MetaClassifierExecutionParameters.isMetaClassifierLocalBetaMaxMethodEnabled)
					columnCount++;
			}		
			
			return columnCount;
		}
	}
	
	/******************************************************************************************/
	public static class predefinedDatasetFoldsResultsTableCreatorClass
	{
	
		public static void printLatexPredefinedDatasetFoldsResultsTableHeaderFirstPartToTheFile(BufferedWriter out, String datasetName)
		{
			/*BufferedWriter out;

		FileWriter fstream = new FileWriter(fileAdditionalProperties);
	    BufferedWriter out = new BufferedWriter(fstream);*/

			try
			{
				out.write("\\begin{table}%[ht])");
				out.write("\n");
				out.write("\\centering");
				out.write("\n");
				out.write("\\caption{");
				out.write(datasetName);
				out.write(" Dataset Folds Results}");
				out.write("\n");
				out.write("\\begin{tabular}{|l|");				
				for(int i=0; i<ConstantVariable.CCA_ConstantVariables.NUMBER_OF_FOLDS_FOR_CONTENT_ONLY; i++)
					out.write("c|");
				out.write("}");
				out.write("\n");
				out.write("\\hline");
				out.write("\n");
				out.write("D. No");
				for(int i=0; i<ConstantVariable.CCA_ConstantVariables.NUMBER_OF_FOLDS_FOR_CONTENT_ONLY; i++)
					out.write("& Ac.("+i+")");
				out.write("\\\\");
				out.write("\n");
				out.write("\\hline");
				out.write("\n");
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}

		}

		public static void addRecordToThePredefinedDatasetFoldsResultsTable(BufferedWriter localOutForPredefinedDatasetFoldsResultsFile, ArrayList<ResultClassListClass> resultsList)
		{
			try
			{
				System.out.println("Ana liste boyutu:"+resultsList.size());
				
				ResultClassListClass resultsListForCO = resultsList.get(0);
				ResultClassListClass resultsListForLO = resultsList.get(1);
				ResultClassListClass resultsListForICA = resultsList.get(2);
				
				ResultClassListClass  resultsListForAVE  = resultsList.get(3);
				ResultClassListClass  resultsListForMAX  = resultsList.get(4);
				ResultClassListClass  resultsListForPROD = resultsList.get(5);
				ResultClassListClass  resultsListForLA   = resultsList.get(6);
				ResultClassListClass  resultsListForDFMM   = resultsList.get(7);
				ResultClassListClass  resultsListForLB   = resultsList.get(8);
				
				ResultClassListClass  resultsListForLAMAX   = resultsList.get(9);
				ResultClassListClass  resultsListForLBMAX   = resultsList.get(10);
				
				int numberOfResultsForCO  = 0;
				int numberOfResultsForLO = 0;
				int numberOfResultsForICA = 0;
				
				int numberOfResultsForAVE  = 0;
				int numberOfResultsForMAX = 0;
				int numberOfResultsForPRD = 0;
				int numberOfResultsForLA = 0;
				int numberOfResultsForDFMM = 0;
				int numberOfResultsForLB = 0;
				int numberOfResultsForLAMAX = 0;
				int numberOfResultsForLBMAX = 0;
				

				if(resultsListForCO != null)
					numberOfResultsForCO = resultsListForCO.size();

				if(resultsListForLO != null)
					numberOfResultsForLO = resultsListForLO.size();

				if(resultsListForICA != null)
					numberOfResultsForICA = resultsListForICA.size();
				
				if(resultsListForAVE != null)
					numberOfResultsForAVE = resultsListForAVE.size();

				if(resultsListForMAX != null)
					numberOfResultsForMAX = resultsListForMAX.size();
				
				if(resultsListForPROD != null)
					numberOfResultsForPRD = resultsListForPROD.size();
				
				if(resultsListForLA != null)
					numberOfResultsForLA = resultsListForLA.size();
				
				if(resultsListForDFMM != null)
					numberOfResultsForDFMM = resultsListForDFMM.size();
				
				if(resultsListForLB != null)
					numberOfResultsForLB = resultsListForLB.size();
				
				if(resultsListForLAMAX != null)
					numberOfResultsForLAMAX = resultsListForLAMAX.size();
				
				if(resultsListForLBMAX != null)
					numberOfResultsForLBMAX = resultsListForLBMAX.size();


				System.out.println("numberOfResultsForCO:"+numberOfResultsForCO);
				System.out.println("numberOfResultsForLO:"+numberOfResultsForLO);
				System.out.println("numberOfResultsForICA:"+numberOfResultsForICA);
				System.out.println("numberOfResultsForAVE:"+numberOfResultsForAVE);
				System.out.println("numberOfResultsForMAX:"+numberOfResultsForMAX);
				System.out.println("numberOfResultsForPROD:"+numberOfResultsForPRD);
				System.out.println("numberOfResultsForLA:"+numberOfResultsForLA);
				System.out.println("numberOfResultsForNCLA:"+numberOfResultsForDFMM);
				System.out.println("numberOfResultsForLB:"+numberOfResultsForLB);
				
				System.out.println("numberOfResultsForLAMAX:"+numberOfResultsForLAMAX);
				System.out.println("numberOfResultsForLBMAX:"+numberOfResultsForLBMAX);
				
				if(resultsListForCO!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForCO, "CO");
				
				if(resultsListForLO!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForLO, "LO");
				
				if(resultsListForICA!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForICA, "ICA");
				
				if(resultsListForAVE!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForAVE, "AVE");
				
				if(resultsListForMAX!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForMAX, "MAX");
				
				if(resultsListForPROD!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForPROD, "PROD");
				
				if(resultsListForLA!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForLA, "wAVE");
				
				if(resultsListForDFMM!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForDFMM, "CNwAVE");
				
				if(resultsListForLB!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForLB, "bAVE");
				
				if(resultsListForLAMAX!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForLAMAX, "LAMAX");
				
				if(resultsListForLBMAX!=null)
					writeFoldResultToThePredefinedDatasetFoldsResultsTable(localOutForPredefinedDatasetFoldsResultsFile, resultsListForLBMAX, "LBMAX");
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}
		static void writeFoldResultToThePredefinedDatasetFoldsResultsTable(BufferedWriter localOutForPredefinedDatasetFoldsResultsFile, ResultClassListClass resultsList, String algorithmName)
		{			
			String RowHeader = predefinedDatasetIndex +"-"+algorithmName;
			
			try
			{
				NumberFormat formatter = new DecimalFormat(ConstantVariable.Format_ConstantVariables.numberFormatToBeUsedForFoldAccuracies);
				
				/*
				localOutForPredefinedDatasetFoldsResultsFile.write(RowHeader + "  & ");

				for(int i=0; i<resultsList.size(); i++)
				{					
					localOutForPredefinedDatasetFoldsResultsFile.write(formatter.format(resultsList.get(i).getEvaluationResultOfWeka().pctCorrect()));
					if(i!=resultsList.size()-1)
						localOutForPredefinedDatasetFoldsResultsFile.write("  & "); 

				}			
				localOutForPredefinedDatasetFoldsResultsFile.write("\\\\");
				localOutForPredefinedDatasetFoldsResultsFile.write("\n");
				localOutForPredefinedDatasetFoldsResultsFile.write("\\hline");
				localOutForPredefinedDatasetFoldsResultsFile.write("\n");*/
				
				//TODO AS EKLEME
				localOutForPredefinedDatasetFoldsResultsFile.write(RowHeader + "  & ");

				for(int i=0; i<resultsList.size(); i++)
				{					
					localOutForPredefinedDatasetFoldsResultsFile.write(formatter.format(resultsList.get(i).getEvaluationResult().getMeasures().getAccuracy()));
					if(i!=resultsList.size()-1)
						localOutForPredefinedDatasetFoldsResultsFile.write("  & "); 

				}			
				localOutForPredefinedDatasetFoldsResultsFile.write("\\\\");
				localOutForPredefinedDatasetFoldsResultsFile.write("\n");
				localOutForPredefinedDatasetFoldsResultsFile.write("\\hline");
				localOutForPredefinedDatasetFoldsResultsFile.write("\n");
			}
			catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}			
		}

		public static void printLatexPredefinedDatasetFoldsResultsTableHeaderEndPartToTheFile(BufferedWriter out, String datasetName)	
		{		
			try
			{
				out.write("\\end{tabular}");
				out.write("\n");			
				out.write("\\label{table:");
				out.write(datasetName);
				out.write("DataFoldsResults}");
				out.write("\n");
				out.write("\\end{table}");
				out.write("\n");
				out.close();
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}
	}
	
	/**************************************Predifined Graph Props-Corrlelations Acc Results****************************************************/
	public static class predefinedDatasetExtendedResultsTableCreatorClass
	{
	
		public static void printLatexPredefinedDatasetExtendedResultsTableHeaderFirstPartToTheFile(BufferedWriter out, String datasetName)
		{
			/*BufferedWriter out;

		FileWriter fstream = new FileWriter(fileAdditionalProperties);
	    BufferedWriter out = new BufferedWriter(fstream);*/

			try
			{
				out.write("\\begin{table}%[ht])");
				out.write("\n");
				out.write("\\centering");
				out.write("\n");
				out.write("\\caption{");
				out.write(datasetName);
				out.write(" Dataset Extended Results}");
				out.write("\n");
				out.write("\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}");
				out.write("\n");
				out.write("\\hline");
				out.write("\n");
				out.write("D. No & avg-kCO & avg-cCO & avg-hCO & avg-alphaCO & avg-accCO & avg-kLO & avg-cLO & avg-hLO & avg-alphaLO & avg-accLO & k(CO)-c(CO) & k(CO)-h(CO) & k(CO)-a(CO) & k(CO)-A(CO) & k(CO)-k(LO) & k(CO)-c(LO) & k(CO)-h(LO) & k(CO)-a(LO)& k(CO)-A(LO) & c(CO)-h(CO) & c(CO)-a(CO) & c(CO)-A(CO) & c(CO)-k(LO) & c(CO)-c(LO) & c(CO)-h(LO) & c(CO)-a(LO) & c(CO)-A(LO) & h(CO)-a(CO) & h(CO)-A(CO) & h(CO)-k(LO) & h(CO)-c(LO) & h(CO)-h(LO) & h(CO)-a(LO) & h(CO)-A(LO) & a(CO)-A(CO) & a(CO)-k(LO) & a(CO)-c(LO) & a(CO)-h(LO) & a(CO)-a(LO) & a(CO)-A(LO) & A(CO)-k(LO) & A(CO)-c(LO) & A(CO)-h(LO) & A(CO)-a(LO) & A(CO)-A(LO) & k(LO)-c(LO) & k(LO)-h(LO) & k(LO)-a(LO) & k(LO)-A(LO) & c(LO)-h(LO) & c(LO)-a(LO) & c(LO)-A(LO) & h(LO)-a(LO) & h(LO)-A(LO) & a(LO)-A(LO) & Acc(CO) & Acc(LO) & Acc(ICA)\\\\");
				out.write("\n");
				out.write("\\hline");
				out.write("\n");
		
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}

		}

		public static void addRecordToThePredefinedDatasetExtendedResultsTable(BufferedWriter localOutForPredefinedDatasetExtendedResultsFile, ArrayList<ResultClassListClass> resultsList, GraphClass graph, Analysis.CorrelationsClass correlations)
		{
			try
			{
				PropertiesOfGraphClass linkProperties = graph.getPropertiesOfTheGraphWithRespectToEdgeType().get(ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE);
				PropertiesOfGraphClass contentProperties = graph.getPropertiesOfTheGraphWithRespectToEdgeType().get(ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH);;
				
				
				
				ResultClassListClass resultsListForCO = resultsList.get(0);
				ResultClassListClass resultsListForLO = resultsList.get(1);
				ResultClassListClass resultsListForICA = resultsList.get(2);
				 
				NumberFormat formatter = new DecimalFormat(ConstantVariable.Format_ConstantVariables.numberFormatToBeUsedForErrorBars);
			
				localOutForPredefinedDatasetExtendedResultsFile.write(predefinedDatasetIndex
						+ " & " + (contentProperties.degreeDistributionRelatedProps==null 		? "-" :formatter.format(contentProperties.degreeDistributionRelatedProps.getAverageDegreeOfNodes()))
						+ " & " + (contentProperties.clusteringCoefficientRelatedProps==null 	? "-" :formatter.format(contentProperties.clusteringCoefficientRelatedProps.getClusteringCoefficientOfTheGraph()))
						+ " & " + (contentProperties.homophilyRelatedProps==null 				? "-" :formatter.format(contentProperties.homophilyRelatedProps.getHomophilyOfTheGraph()))
						+ " & " + (contentProperties.localAlphaRelatedProps==null 				? "-" :formatter.format(contentProperties.localAlphaRelatedProps.getLocalAlphaOfTheGraph()))
						+ " & " + (contentProperties.accuracyRelatedProps==null 				? "-" :formatter.format(contentProperties.accuracyRelatedProps.getAccuracyOfTheGraph()))
						
						+ " & " + (linkProperties.degreeDistributionRelatedProps==null 			? "-" :formatter.format(linkProperties.degreeDistributionRelatedProps.getAverageDegreeOfNodes()))
						+ " & " + (linkProperties.clusteringCoefficientRelatedProps==null 		? "-" :formatter.format(linkProperties.clusteringCoefficientRelatedProps.getClusteringCoefficientOfTheGraph()))
						+ " & " + (linkProperties.homophilyRelatedProps==null 					? "-" :formatter.format(linkProperties.homophilyRelatedProps.getHomophilyOfTheGraph()))
						+ " & " + (linkProperties.localAlphaRelatedProps==null 					? "-" :formatter.format(linkProperties.localAlphaRelatedProps.getLocalAlphaOfTheGraph()))
						+ " & " + (linkProperties.accuracyRelatedProps==null 					? "-" :formatter.format(linkProperties.accuracyRelatedProps.getAccuracyOfTheGraph()))
						
						+ " & " + formatter.format(correlations.getCor_kCO_cCO())+ " & "+ formatter.format(correlations.getCor_kCO_hCO())+ " & "+ formatter.format(correlations.getCor_kCO_alphaCO())
						+ " & " + formatter.format(correlations.getCor_kCO_accuracyCO()) + "& " + formatter.format(correlations.getCor_kCO_kLO())+ "& " + formatter.format(correlations.getCor_kCO_cLO())
						+ " & " + formatter.format(correlations.getCor_kCO_hLO())+ "& " + formatter.format(correlations.getCor_kCO_alphaLO())+ "& " + formatter.format(correlations.getCor_kCO_accuracyLO())
						+ " & " + formatter.format(correlations.getCor_cCO_hCO())+ "& "+ formatter.format(correlations.getCor_cCO_alphaCO())+ "& "+ formatter.format(correlations.getCor_kCO_accuracyCO())
						+ " & " + formatter.format(correlations.getCor_cCO_kLO())+ "& " + formatter.format(correlations.getCor_cCO_cLO())+ "& " + formatter.format(correlations.getCor_cCO_hLO())
						+ " & " + formatter.format(correlations.getCor_cCO_alphaLO()) + "& " + formatter.format(correlations.getCor_cCO_accuracyLO()) + "& " + formatter.format(correlations.getCor_hCO_alphaCO())
						+ " & " + formatter.format(correlations.getCor_hCO_accuracyCO())+ "& " + formatter.format(correlations.getCor_hCO_kLO())+ "& " + formatter.format(correlations.getCor_hCO_cLO())
						+ " & " + formatter.format(correlations.getCor_hCO_hLO())+ "& " + formatter.format(correlations.getCor_hCO_alphaLO())+ "& " + formatter.format(correlations.getCor_hCO_accuracyLO())
						+ " & " + formatter.format(correlations.getCor_alphaCO_accuracyCO())+ "& " +formatter.format(correlations.getCor_alphaCO_kLO())+ "& " + formatter.format(correlations.getCor_alphaCO_cLO())
						+ " & " + formatter.format(correlations.getCor_alphaCO_hLO())+ "& " + formatter.format(correlations.getCor_alphaCO_alphaLO())+ "& " + formatter.format(correlations.getCor_alphaCO_accuracyLO()) 
						+ " & " + formatter.format(correlations.getCor_accuracyCO_kLO())+ "& " + formatter.format(correlations.getCor_accuracyCO_cLO())+ "& " + formatter.format(correlations.getCor_accuracyCO_hLO())
						+ " & " + formatter.format(correlations.getCor_accuracyCO_alphaLO())+ "& " + formatter.format(correlations.getCor_accuracyCO_accuracyLO())+"& " + formatter.format(correlations.getCor_kLO_cLO())
						+ " & " + formatter.format(correlations.getCor_kLO_hLO())+ "& " + formatter.format(correlations.getCor_kLO_alphaLO())+ "& " + formatter.format(correlations.getCor_kLO_accuracyLO())
						+ " & " + formatter.format(correlations.getCor_cLO_hLO())+ "& " + formatter.format(correlations.getCor_cLO_alphaLO())+ "& " + formatter.format(correlations.getCor_cLO_accuracyLO())
						+ " & " + formatter.format(correlations.getCor_hLO_alphaLO())+ "& " + formatter.format(correlations.getCor_hLO_accuracyLO())+ "& "+ formatter.format(correlations.getCor_alphaLO_accuracyLO())
				
						+ "  & " + (resultsListForCO==null ? "-" :formatter.format(resultsListForCO.calculateAverageAccuracyObtained()) + " $\\pm$ " + formatter.format(resultsListForCO.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForLO==null ? "-" : formatter.format(resultsListForLO.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForLO.findErrorBarOfAccuracyResults()))
						+ "  & " + (resultsListForICA==null ? "-" :formatter.format(resultsListForICA.calculateAverageAccuracyObtained())+ " $\\pm$ " + formatter.format(resultsListForICA.findErrorBarOfAccuracyResults())) 
						+"\\\\");
				localOutForPredefinedDatasetExtendedResultsFile.write("\n");
				localOutForPredefinedDatasetExtendedResultsFile.write("\\hline");
				localOutForPredefinedDatasetExtendedResultsFile.write("\n");
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}

		public static void printLatexPredefinedDatasetExtendedResultsTableHeaderEndPartToTheFile(BufferedWriter out, String datasetName)	
		{		
			try
			{
				out.write("\\end{tabular}");
				out.write("\n");			
				out.write("\\label{table:");
				out.write(datasetName);
				out.write("DatasetExtendedResults}");
				out.write("\n");
				out.write("\\end{table}");
				out.write("\n");
				out.close();
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}
	}
}
